home *** CD-ROM | disk | FTP | other *** search
- Path: dte.detroitedison.com!news
- From: "mccardellc@detroitedison.com" <mccardellc@detroitedison.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Pointer to interrupt method in BC 4.52
- Date: 14 Mar 1996 23:32:24 GMT
- Organization: Detroit Edison
- Message-ID: <4iaaa8$oc6@news.deco.com>
- References: <4i9sho$3mj@masala.cc.uh.edu>
- NNTP-Posting-Host: 162.9.222.240
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; U; 16bit)
-
- pmn12564@Bayou.UH.EDU (pat neff) wrote:
- > I have a class in which one of the methods is an interrupt. Since I need
- >to hook the interrupt into the interrupt table, I need a pointer to it.
- >Something like:
- >
- >class myobject {
- >
- >void interrupt myinterrupt(...);
- >void dohook ();
- >}
- >
- >void interrupt myobject::myinterrupt (...)
- >{
- > // actuall interrupt code here
- >}
- >
- >void myobject::dohook ()
- >{
- > setvect (0x??, this->myinterrupt);
- >}
- >
- > This compiler complains about the line with SETVECT saying I need to
- >call or take the address of the interrupt function. I am trying to take the
- >address of course. I have tried everything, but NO LUCK! Can anyone out
- >there help me?
- >
-
-
- The only way to have a member function called by an interrupt is to
- make it a static function.
-
- Static functions are functions which are available to a class without
- instances of the class being declared.
-
- The code would look like this:
-
- class myobject {
- public:
- static void interrupt myinterrupt(...);
-
- void dohook ();
- }
-
- void interrupt myobject::myinterrupt (...)
- {
- // actuall interrupt code here
- }
-
- void myobject::dohook ()
- {
- setvect (0x??, myobject::myinterrupt);
- }
-
- Note: You can't access the 'this' pointer within a static object,
- therefore your member variables are NOT accessable in the interrupt
- function.
-
- Good luck!
-
-
- Clifford McCardell
-
-
-